# {{ ansible_managed }}

# https://etcd.io/docs/v3.5/op-guide/configuration/

name: {{ etcd_instance }}

data-dir: {{ etcd_data }}

#enable-v2: yes

initial-cluster-token: "{{ etcd_cluster }}"

initial-cluster-state: "{{ etcd_init|default('new') }}"

initial-cluster: "{% for ip in groups['etcd']|sort %}{% if not loop.first %},{% endif %}{{ etcd_cluster }}-{{ hostvars[ip].etcd_seq }}=https://{{ ip }}:{{ etcd_peer_port }}{% endfor %}"

initial-advertise-peer-urls: "https://{{ inventory_hostname }}:{{ etcd_peer_port }}"

listen-peer-urls: "https://{{ inventory_hostname }}:{{ etcd_peer_port }}"

listen-client-urls: "https://{{ inventory_hostname }}:{{ etcd_port }},https://127.0.0.1:{{ etcd_port }}"

advertise-client-urls: "https://{{ inventory_hostname }}:{{ etcd_port }}"

election-timeout: {{ etcd_election_timeout|default(1000) }}

heartbeat-interval: {{ etcd_heartbeat_interval|default(100) }}

auto-compaction-mode: periodic
auto-compaction-retention: "24h"

client-transport-security:
  cert-file: "/etc/etcd/server.crt"
  key-file:  "/etc/etcd/server.key"
  trusted-ca-file: "/etc/etcd/ca.crt"

peer-transport-security:
  cert-file: "/etc/etcd/server.crt"
  key-file:  "/etc/etcd/server.key"
  trusted-ca-file: "/etc/etcd/ca.crt"
